﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace winform
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void Form3_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“biaooDataSet1.Orderproduct”中。您可以根据需要移动或删除它。
            var ABC = "select*from Orderproduct";
            var stuSql = "select*from students";

            var dt = Class1.GetDataTable(stuSql);
            
            dataGridView1.DataSource = dt;
            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dataGridView1.ReadOnly = true;
            dataGridView1.AllowUserToAddRows = false;

        }

        private void button4_Click(object sender, EventArgs e)
        {
            var name = dsasgf.Text;
            var sql = string.Format("select*from Students where StudentName like '%{0}'", name);
            var dt = Class1.GetDataTable(sql);
            dataGridView1.DataSource=dt;
            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dataGridView1.ReadOnly = true;
            dataGridView1.AllowUserToAddRows = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //添加
            Form4 form = new Form4();
            form.Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //更新
            var id = dataGridView1.SelectedRows[0].Cells["Id"].Value;
            form4 Form = new Form4();
            Form.Show();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            //删除
        }
    }
}
